package com.zeldu.question.controller;

import com.zeldu.common.model.response.CommonCode;
import com.zeldu.common.model.response.QueryResponseResult;
import com.zeldu.common.model.response.QueryResult;
import com.zeldu.question.pojo.questionLibrary;
import com.zeldu.question.service.PaperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("paper")
public class PaperController {

    @Autowired(required = false)
    private PaperService paperService;

    @RequestMapping("/get")
    @ResponseBody
    public QueryResponseResult<questionLibrary> queryAll(Long paper_id){
        QueryResult<questionLibrary> queryResult=new QueryResult<>();
        List<questionLibrary> exams = paperService.questions(paper_id);
        queryResult.setList(exams);
        queryResult.setTotal(exams.size());
        return new QueryResponseResult<>(CommonCode.SUCCESS,queryResult);
    }
    @RequestMapping("/finish")
    @ResponseBody
    public QueryResponseResult<questionLibrary> queryFinish(Long examId){
        QueryResult<questionLibrary> queryResult=new QueryResult<>();
        List<questionLibrary> exams = paperService.finish_ques(examId);
        queryResult.setList(exams);
        queryResult.setTotal(exams.size());
        return new QueryResponseResult<>(CommonCode.SUCCESS,queryResult);
    }

}
